import { createRouter, createWebHistory } from 'vue-router'

// 定义路由组件，这些组件将在后面创建
const Home = () => import('../views/Home.vue')
const UserManagement = () => import('../views/UserManagement.vue')
const DepartmentManagement = () => import('../views/DepartmentManagement.vue')
const RoleManagement = () => import('../views/RoleManagement.vue')

const Settings = () => import('../views/Settings.vue')
const MaterialCategory = () => import('../views/MaterialCategory.vue')
const MaterialInfo = () => import('../views/MaterialInfo.vue')
const SupplierManagement = () => import('../views/SupplierManagement.vue')
// 采购管理相关组件
const PurchaseOrder = () => import('../views/PurchaseOrder.vue')

const EBOMManagement = () => import('../views/EBOMManagement.vue')

// 路由配置
const routes = [
  // 研发管理模块下的产品BOM子菜单
  { path: '/research/ebom', name: 'EBOMManagement', component: EBOMManagement },
  // 销售管理模块
  { path: '/sales/contract', name: 'SalesContract', component: () => import('../views/SalesContract.vue'), meta: { title: '销售合同', parent: 'sales' } },
  { path: '/sales/order', name: 'SalesOrder', component: () => import('../views/SalesOrder.vue'), meta: { title: '销售订单', parent: 'sales' } },
  { path: '/', name: 'Home', component: Home },
  { path: '/system/user', name: 'UserManagement', component: UserManagement },
  { path: '/system/department', name: 'DepartmentManagement', component: DepartmentManagement },
  { path: '/system/role', name: 'RoleManagement', component: RoleManagement },

  { path: '/settings', name: 'Settings', component: Settings },
  { path: '/material/category', name: 'MaterialCategory', component: MaterialCategory },
  { path: '/material/info', name: 'MaterialInfo', component: MaterialInfo },
  { path: '/basic/supplier', name: 'SupplierManagement', component: SupplierManagement },
  { path: '/basic/customer', name: 'CustomerManagement', component: () => import('../views/CustomerManagement.vue'), meta: { title: '客户管理', parent: 'basic' } },
  { path: '/basic/workshop', name: 'WorkshopManagement', component: () => import('../views/WorkshopManagement.vue'), meta: { title: '生产车间', parent: 'basic' } },

    { path: '/basic/material-category', name: 'MaterialCategory', component: MaterialCategory, meta: { title: '物料分类', parent: 'basic' } },
    { path: '/basic/material-info', name: 'MaterialInfo', component: MaterialInfo, meta: { title: '物料信息', parent: 'basic' } },
  // 采购管理相关路由
  // 采购管理模块
  { path: '/purchase/order', name: 'PurchaseOrder', component: PurchaseOrder, meta: { title: '采购订单', parent: 'purchase' } },
  { path: '/purchase/receipt', name: 'PurchaseReceipt', component: () => import('../views/PurchaseReceipt.vue'), meta: { title: '采购到货单', parent: 'purchase' } },
  // 仓库管理相关路由
// 注意：仓库管理是一级菜单无页面，仅作为库存管理、仓库列表和采购入库的父菜单
{ path: '/warehouse/list', name: 'WarehouseList', component: () => import('../views/WarehouseList.vue'), meta: { title: '仓库列表', parent: 'warehouse' } },
{ path: '/warehouse/inventory', name: 'InventoryManagement', component: () => import('../views/InventoryManagement.vue'), meta: { title: '库存管理', parent: 'warehouse' } },
{ path: '/warehouse/stock-in', name: 'PurchaseStockIn', component: () => import('../views/PurchaseStockIn.vue'), meta: { title: '采购入库', parent: 'warehouse' } }
]

// 创建路由实例
const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router